home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 July
/
Macworld (1999-07).dmg
/
Shareware World
/
Info
/
For Developers
/
Mops 3.4.sea
/
Mops source
/
Toolbox classes
/
Menu
< prev
next >
Wrap
Text File
|
1998-01-11
|
2KB
|
97 lines
\ Menu class.
\ Sept 90 mrh item# anomalies fixed
\ Sept 97 mrh updated for PowerMops
syscall NewMenu
syscall GetMenu
syscall MenuSelect
syscall DrawMenuBar
syscall ClearMenuBar
syscall MenuKey
syscall EnableItem
syscall DisableItem
syscall HiliteMenu
syscall GetMenuItemText
syscall SetMenuItemText
syscall InsertMenuItem
syscall DeleteMenuItem
syscall InsertMenu
syscall InsertResMenu
syscall AppendMenu
syscall AppendResMenu
syscall CheckItem
syscall OpenDeskAcc
syscall SystemEdit
syscall ReleaseResource
from MENUMOD import{ MENU APPLEMENU EDITMENU }
compile: menuMod
lock: menuMod
true setInstall: MenuMod
: DODSK \ ( item# -- ) Executes the desk accessory for an item.
\ Note we can send a late-bound msg to self even though we're
\ not lexically in a class, since this word will only be called
\ from a method.
openDesk: [self] ;
: MSELECT \ ( point -- item# menuID ) Calls menu manager to track a menu selection
MenuSelect unpack swap 1- swap ;
:class MBAR super{ object }
24 ordered-col IDs
24 array MENUS \ array of menu objects
:m DRAW: DrawMenuBar ;m
:m CLEAR: ClearMenuBar clear: IDs ;m
:m ADD: \ ( men1 ... menN N -- ) Adds menu objects to the MenuBar object.
0 DO i to: menus i at: menus id: [] add: ids LOOP ;m
:m NEW: \ Inserts menus in Toolbox MenuBar list.
size: IDs 0
DO size: IDs 1- i - at: menus insert: [] LOOP
draw: self ;m
:m INIT: \ ( men1 ... menN N -- )
clear: self add: self new: self ;m
:m EXEC: \ ( item# MenuID -- )
dup 0>
IF indexOf: IDs IF at: menus exec: [] THEN
ELSE 2drop
THEN ;m
:m CLICK: where: fevent mSelect exec: self ;m
:m KEY: \ ( c -- ) Handles a possible menu key selection
MenuKey unpack swap 1- swap
exec: self ;m
:m ENABLE: \ Enables all menus in the Menu Bar
size: IDs 0
DO i at: menus handle: [] 0 EnableItem LOOP
draw: self ;m
:m DISABLE:
size: IDs 0
DO i at: menus handle: [] 0 DisableItem LOOP
draw: self ;m
;class
mBar MENUBAR \ Our default menu bar
menubar put: MBaddr \ Set as current menu bar